package com.shotinthedark.ordinance
{
	import com.shootingGame.GamePlayManager;
	import com.shootingGame.Player;
	import com.shootingGame.physics.collisionReactionClasses.base.CollisionEffects;
	import com.shootingGame.renderableClasses.GameObject;
	import com.shootingGame.weaponsClasses.WeaponInfo;
	import com.shootingGame.weaponsClasses.ordinance.Ordinance;
	import com.shootingGame.weaponsClasses.ordinance.RocketOrdinance;
	
	import flash.geom.Point;

	public class GuidedRocketOrdinance extends RocketOrdinance
	{	
		
		public function GuidedRocketOrdinance(owner : GameObject, weaponInfo : WeaponInfo, collisionEffects:CollisionEffects = null, sourceX:Number = 0, sourceY:Number = 0, targetX:Number = 0, targetY:Number = 0, travelDirection:Number = 0, travelSpeedModifier:Number = 1, liveTime : int = 10000)
		{
			super(owner, weaponInfo, collisionEffects, sourceX, sourceY, targetX, targetY, travelDirection, travelSpeedModifier, liveTime);
		}
		
		override protected function updateThrust():void{
			//INEVITABLE CHANGE MARKER
			//The following line(s) of code will need to be changed in future.
			//Reason: SCROLLING MAP and memory storage of non-rendered off-screen objects (essential server function).
			if(liveTimeRemaining == int.MAX_VALUE)
				return;
			var player:Player;
			if(owner is Player){
				player = owner as Player;
				if(player.isPrimaryPlayer){
					if(parent){
						target.x = parent.mouseX;
						target.y = parent.mouseY;
						source.x = memoryX;
						source.y = memoryY;
					}
				}
				else{
//					target.x = player.keyStates.MOUSE_X + (player.memoryX - GamePlayManager.stageWidth);
//					target.y = player.keyStates.MOUSE_Y + (player.memoryY - GamePlayManager.stageHeight);
//					source.x = memoryX + (player.memoryX - GamePlayManager.stageWidth);
//					source.y = memoryY + (player.memoryY - GamePlayManager.stageHeight);
				}
			}
			

			super.updateThrust();
		}

		override public function clone():Ordinance{
			return new GuidedRocketOrdinance(owner, weaponInfo);
		}		
	}
}
